var EditableHeader_Instances = [];

function EditableHeader(id)
{
    this.superClase = EditableGroup;
    this.superClase(id);
    
    this.idParts = [];      
    this.validatorID = "";    
    this.visibility = true;
    
    // Public Functions
    this.show = EditableHeader_Show;
    this.hide = EditableHeader_Hide;
    this.getValue = EditableHeader_GetValue;
    this.setValue = EditableHeader_SetValue;
    this.cleanValue = EditableHeader_CleanValue;
    this.getDescription = EditableHeader_GetDescription;
    this.setDescription = EditableHeader_SetDescription;
    
    // Internal Functions
    this.validate = EditableHeader_Validate;     
    this.disableIdParts = EditableHeader_DisableIdParts;
        
    EditableHeader_Instances[id] = this;
} 


// --------------------------------------------------------------------------------------------------
// Public Functions
// --------------------------------------------------------------------------------------------------

function EditableHeader_Show()
{
    var cont = document.getElementById("panel_" + this.id);
    if(!cont)
        cont = document.getElementById(this.id);
        
    cont.style.display = '';
    this.visibility = true;
}

function EditableHeader_Hide()
{
    var cont = document.getElementById("panel_" + this.id);
    if(!cont)
        cont = document.getElementById(this.id);
        
    cont.style.display = 'none';
    this.visibility = false;
}

function EditableHeader_GetValue(id)
{
    var index = this.getIndexControl(id);
    if(index < 0) {
        alert("There is no item called " + id + " in group " + this.id);
    }
    else {
        var value = this.getItemValue(index);
        return value;
    }
}

function EditableHeader_SetValue(id, value)
{
    var index = this.getIndexControl(id);
    if(index < 0)
        alert("There is no item called " + id + " in group " + this.id);
    else        
        this.setItemValue(index, value);
}

function EditableHeader_GetDescription(id)
{
    var index = this.getIndexControl(id);
    if(index < 0) {
        alert("There is no item called " + id + " in group " + this.id);
    }
    else {
        var description = this.getItemDescription(index);
        return description;
    }
}

function EditableHeader_SetDescription(id, description)
{
    var index = this.getIndexControl(id);
    if(index < 0)
        alert("There is no item called " + id + " in group " + this.id);
    else       
        this.setItemDescription(index, description);
}

function EditableHeader_CleanValue(id) {
    var index = this.getIndexControl(id);
    if (index < 0)
        alert("There is no item called " + id + " in group " + this.id);
    else
        this.cleanItemValue(index);
}


// --------------------------------------------------------------------------------------------------
// Internal Functions
// --------------------------------------------------------------------------------------------------

function EditableHeader_Validate()
{
    return Validate(this.validatorID);
}

// [IdParts]: apago los campos que son parte del id
function EditableHeader_DisableIdParts()
{
    for(var i=0; i<this.idParts.length; i++) {
        this.disableItem(this.idParts[i]);
    }
}
